package com.matuw.android.adapter;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;


public interface UniversalAdapter<T, VH extends UniversalHolder<T>> {

    int getItemCount();

    int getItemType(int position);

    boolean isEmpty();

    @NonNull
    VH onCreateItemHolder(@NonNull ViewGroup parent, int viewType);

    /**
     * 渲染 item 界面，消除 RecyclerView 与 ListView 差异
     */
    void render(@NonNull VH holder, int position);

    /**
     * 局部 item 刷新
     */
    void render(@NonNull VH holder, int position, @NonNull List<Object> payloads);

    void notifyDataSetChanged();

    void notifyItemChanged(int position);

    void notifyItemChanged(int position, @Nullable Object payload);

    void notifyItemRangeChanged(int positionStart, int itemCount);

    void notifyItemRangeChanged(int positionStart, int itemCount, @Nullable Object payload);

    void notifyItemInserted(int position);

    void notifyItemRangeInserted(int positionStart, int itemCount);

    void notifyItemRemoved(int position);

    void notifyItemRangeRemoved(int positionStart, int itemCount);
}
